/*
   @Descripttion
   @version
   @Author         Xiaoqi Lai
   @Date           2021-07-05 16:38:11
   @LastEditors    Xiaoqi Lai
   @LastEditTime   2021-07-05 16:53:05
*/

#include "MyLCD.h"
#include "MyDHT.h"
#include "MyEngine.h"
#include "MYALARM.h"
#include "LightControl.h"
#include "WindowSensor.h"
#include "DoorSensor.h"
#include "lightSensor.h"
#include "operation.h"
#include "MYPINLINE.h"
#include "FireSensor.h"
#include "Water.h"

extern int flaglight;

void setup()
{
  Serial.begin(74880);

  DHTinit();
  LCDInit();
  Doorinit();
  alarminit();
  lightinit();
  windowinit();
  doorSinit();
  lightSensorinit();
  Waterinit();
  Fireinit();
  operateinit();
  //Serial.println("1");
}

void loop()
{
  changeOperation();
  doorSensor();
  windowSensor();
  alarmUse();
  waterSensor();
  fireSensor();

  if(flaglight == 1)
  {
    int sensor_value = analogRead(lightSen);
    if (sensor_value < 800)// the point at which the state of LEDs change
    {
         digitalWrite(lightControlPin, HIGH);
    }
    else
    {
         digitalWrite(lightControlPin,LOW); //Sets LEDs OFF
    } 
  }


  
}
